﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.Entity;
using MealCardManagement.Data;
using MealCardManagement.Data.Migrations;
using System.Data.Entity.Migrations;
using System.Data.Entity.Migrations.Infrastructure;

namespace MealCardManagement.Client
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            InitialDatabase();
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new MainForm());            
        }

        static void InitialDatabase()
        {
            using (var context = new MCMContext())
            {
                if (!context.Database.Exists())
                {
                    var config = new Configuration();
                    var migrator = new DbMigrator(config);
                    migrator.Update();
                }
            }
        }
    }
}
